// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-11

package responses

import (
	"gitee.com/go-libs/db-xorm/db"
	"server/app/http/models"
	"server/app/kind"
)

// ArcadeFinanceResponse
// 钓场财务流水.
type ArcadeFinanceResponse struct {
	Id       int64
	ArcadeId kind.ArcadeId
	Date     db.Date
	Internal int
	RecordId int64
	UserId   kind.UserId
	Type     kind.FinanceType
	TypeText string
	Cost     kind.Balance
	Kind     kind.FinanceKind
	KindPage string
	KindText string
	Params   string
	Message  string
	Datetime string

	User *UserResponse `json:",omitempty"`
}

// With
// 数据绑定.
func (o *ArcadeFinanceResponse) With(m *models.ArcadeFinance) *ArcadeFinanceResponse {
	o.Id = m.Id
	o.ArcadeId = m.ArcadeId
	o.Date = m.Date
	o.Datetime = m.CreatedAt.Time().Format("2006/01/02 15:04")
	o.Internal = m.Internal
	o.RecordId = m.RecordId
	o.UserId = m.UserId
	o.Type = m.Type
	o.TypeText = m.Type.Text()
	o.Cost = m.Cost
	o.Kind = m.Kind
	o.KindPage = m.Kind.Page()
	o.KindText = m.Kind.Text()
	o.Params = m.Params
	o.Message = m.Message
	return o
}

// WithUser
// 绑定用户.
func (o *ArcadeFinanceResponse) WithUser(m *models.Users) *ArcadeFinanceResponse {
	if m != nil {
		o.User = (&UserResponse{}).With(m)
	}
	return o
}
